/**
 * Created by Administrator on 2017/5/17.
 */

var indexs=0;
$(function(){
    //=====更新大屏，小屏=====
    gengxinpicS();
    gengxinpicN();
    getcountS();
    getcountN();
    index0();
    $(".index_nav ul li").each(function(index){
        $(this).click(function(){
            $(this).addClass("nav_active").siblings().removeClass("nav_active");
            $(".index_tabs .inner").eq(index).fadeIn().siblings("div").stop().hide();
            if(index==0){
                indexs=0;
                disconnect();
                disconnect1();
                disconnect3();
                clearIf();
                index0();
            }else
            if(index==1){
                indexs=1;
               disconnect();
               disconnect1();
                disconnect3();
                clearIf();
                index1();
            }else if(index==2){
                indexs=2
                disconnect();
                disconnect1();
                disconnect3();
                clearIf();
                index2();
            }else if(index==3){
                indexs=3;
                disconnect();
                disconnect1();
                disconnect3();
                clearIf();
                index3();
            }else if(index==4){
                indexs=4;
                disconnect();
                disconnect1();
                disconnect3();
                clearIf();


                index4();
            }else if(index==5){
                indexs=5;
                index5();
                disconnect();
                disconnect1();
                disconnect3();
                clearIf();
            }else if(index==6){
                indexs=6
                disconnect();
                disconnect1();
                disconnect3();
                clearIf();
                manage();
            }
        })
    });
    $(".tabs ul li").each(function(index){
       $(this).click(function(){
           $(".tabs ul li div .div").removeClass("tabs_active");
           $(this).find("div .div").addClass("tabs_active");
           $(".tabs_map>div").eq(index).fadeIn().siblings("div").stop().hide();
       })
   });
    $(".middle_top_bot ul li").each(function(){
        $(this).click(function(){
            $(".middle_top_bot ul li").removeClass("middle_top_bot_active");
            $(this).addClass("middle_top_bot_active");
        })
    });

});

var index30secInterval;
var index0oneInterval;
var index0fiveInterval;
var index010secInterval;
function index0() {
    if(oWebControl1==null){
        initPlugin1();
    }
    if(oWebControl2==null){
        initPlugin2();
    }
    index030sec();
    index0one();
    index0five();
    checkEmptycw();
    //0
    clearInterval(index30secInterval);
    clearInterval(index0oneInterval);
    clearInterval(index0fiveInterval);
    clearInterval(index010secInterval);
    //1
    clearInterval(index1oneInterval);
    //2
    clearInterval(index2fiveInterval);
    //3
    clearInterval(xiaopingNgengxin);
    clearInterval(dapingNgengxin);
    clearInterval(xiaopingNgengxinN);
    clearInterval(dapingNgengxinN);
    //4
    clearInterval(queryParking);

    index30secInterval=setInterval(index030sec,30000);
    index0oneInterval=setInterval(index0one,60000);
    index0fiveInterval=setInterval(index0five,300000);
    index010secInterval = setInterval(checkEmptycw,60000);

}



var queryParking;
function index4(){
    if(oWebControl3==null){
        initPlugin3();
    }
    cwStatistics();
    cwzyl();
    queryParkingz();
    //0
    clearInterval(index30secInterval);
    clearInterval(index0oneInterval);
    clearInterval(index0fiveInterval);
    clearInterval(index010secInterval);
    //1
    clearInterval(index1oneInterval);
    //2
    clearInterval(index2fiveInterval);
    //3
    clearInterval(xiaopingNgengxin);
    clearInterval(dapingNgengxin);
    clearInterval(xiaopingNgengxinN);
    clearInterval(dapingNgengxinN);
    //4
    clearInterval(queryParking);
    queryParking = setInterval(queryParkingz,60000);

}
function manage(){
    //0
    clearInterval(index30secInterval);
    clearInterval(index0oneInterval);
    clearInterval(index0fiveInterval);
    clearInterval(index010secInterval);
    //1
    clearInterval(index1oneInterval);
    //2
    clearInterval(index2fiveInterval);
    //3
    clearInterval(xiaopingNgengxin);
    clearInterval(dapingNgengxin);
    clearInterval(xiaopingNgengxinN);
    clearInterval(dapingNgengxinN);
    //4
    clearInterval(queryParking);

    if(oWebControl==null){
        initPlugin();
    }

}



var index1oneInterval;
function index1(){
    //0
    clearInterval(index30secInterval);
    clearInterval(index0oneInterval);
    clearInterval(index0fiveInterval);
    clearInterval(index010secInterval);
    //1
    clearInterval(index1oneInterval);
    //2
    clearInterval(index2fiveInterval);
    //3
    clearInterval(xiaopingNgengxin);
    clearInterval(dapingNgengxin);
    clearInterval(xiaopingNgengxinN);
    clearInterval(dapingNgengxinN);
    //4
    clearInterval(queryParking);

    index1one();
    carFlowChart();
    carfrom();
    carGroupChart();
    ckllCount();
    peopleCount();
    peopleFlowChart();
    contrastChart();
    index1five();
    index1oneInterval=setInterval(index1five,60000);
}

var index2fiveInterval;
function index2(){
    //0
    clearInterval(index30secInterval);
    clearInterval(index0oneInterval);
    clearInterval(index0fiveInterval);
    clearInterval(index010secInterval);
    //1
    clearInterval(index1oneInterval);
    //2
    clearInterval(index2fiveInterval);
    //3
    clearInterval(xiaopingNgengxin);
    clearInterval(dapingNgengxin);
    clearInterval(xiaopingNgengxinN);
    clearInterval(dapingNgengxinN);
    //4
    clearInterval(queryParking);

    sailCount();
    dpSailChart1();
    salesCurve();
    allAly();
    realTimeOrder();
    kdj();
    averagePrice();
    index2five();
    index2fiveInterval=setInterval(index2five,300000);
}

var xiaopingNgengxin;
var dapingNgengxin;
var xiaopingNgengxinN;
var dapingNgengxinN;
function index3(){
    //0
    clearInterval(index30secInterval);
    clearInterval(index0oneInterval);
    clearInterval(index0fiveInterval);
    clearInterval(index010secInterval);
    //1
    clearInterval(index1oneInterval);
    //2
    clearInterval(index2fiveInterval);
    //3
    clearInterval(xiaopingNgengxin);
    clearInterval(dapingNgengxin);
    clearInterval(xiaopingNgengxinN);
    clearInterval(dapingNgengxinN);
    //4
    clearInterval(queryParking);

    getcountS();
    gengxinpicS();
    getcountN();
    gengxinpicN();

    xiaopingNgengxin = setInterval(getcountS,30000);
    dapingNgengxin = setInterval(gengxinpicS,60000);
    xiaopingNgengxinN = setInterval(getcountN,30000);
    dapingNgengxinN = setInterval(gengxinpicN,60000);
}
function index5(){
    checkEmptycw();
    //0
    clearInterval(index30secInterval);
    clearInterval(index0oneInterval);
    clearInterval(index0fiveInterval);
    clearInterval(index010secInterval);
    //1
    clearInterval(index1oneInterval);
    //2
    clearInterval(index2fiveInterval);
    //3
    clearInterval(xiaopingNgengxin);
    clearInterval(dapingNgengxin);
    clearInterval(xiaopingNgengxinN);
    clearInterval(dapingNgengxinN);
    //4
    clearInterval(queryParking);

    index010secInterval = setInterval(checkEmptycw,60000);
}

/****************第一标签方法开始*************************/
//30秒定时任务
function index030sec() {
    cllCount();
    kllTodayCount();
}


//1分钟定时任务
function index0one() {

    xsTodayCount();
    queryParkingSpace();
}
//5分钟定时任务
function index0five() {
    cllChart(0);
    dpSailChart();
    sailChart(0);
    nbSailChart(0);
    kllChart(0);
}
//查询厕所剩余坑位
function checkEmptycw(){
    $.ajax({
        type: "POST",
        url: "../../cw/cwparking/checkEmptycw",
        data: {

        },
        success: function(r) {
            var list = r.list;
            //====连不上算没人
            $("#nanS").html(10-Number(list[0]));
            $("#nanN").html(10-Number(list[1]));
            $("#nvS").html(40-Number(list[2]));
            $("#nvN").html(40-Number(list[3]));
            $("#manuses").html(list[0]);
            $("#manusen").html(list[1]);
            $("#womanuses").html(list[2]);
            $("#womanusen").html(list[3]);
            $("#manunuses").html(10-Number(list[0]));
            $("#manunusen").html(10-Number(list[1]));
            $("#womanunuses").html(40-Number(list[2]));
            $("#womanunusen").html(40-Number(list[3]));
            var nlist  = list[4];
            var slist = list[5];
            var map = list[6];
            var listz = list[7];
            for (let i = 0; i <listz.length ; i++) {
                if(JSON.stringify(nlist).indexOf(JSON.stringify(listz[i])) != -1){
                    $("#n"+listz[i]).attr("src","../../statics/css/img/"+map[listz[i]]+"red.png");
                }else{
                    $("#n"+listz[i]).attr("src","../../statics/css/img/"+map[listz[i]]+"green.png");
                }
                if(JSON.stringify(slist).indexOf(JSON.stringify(listz[i])) != -1){
                    $("#s"+listz[i]).attr("src","../../statics/css/img/"+map[listz[i]]+"red.png");
                }else{
                    $("#s"+listz[i]).attr("src","../../statics/css/img/"+map[listz[i]]+"green.png");
                }
            }
            /*$("#nanS").html(list[0]);
            $("#nanN").html(list[1]);
            $("#nvS").html(list[2]);
            $("#nvN").html(list[3]);
            $("#manunuses").html(list[0]);
            $("#manunusen").html(list[1]);
            $("#womanunuses").html(list[2]);
            $("#womanunusen").html(list[3]);
            $("#manuses").html(10-Number(list[0]));
            $("#manusen").html(10-Number(list[1]));
            $("#womanuses").html(40-Number(list[2]));
            $("#womanusen").html(40-Number(list[3]));
            var nlist  = list[4];
            var slist = list[5];
            var map = list[6];
            var listz = list[7];
            for (let i = 0; i <listz.length ; i++) {
                if(JSON.stringify(nlist).indexOf(JSON.stringify(listz[i])) == -1){
                    $("#n"+listz[i]).attr("src","../../statics/css/img/"+map[listz[i]]+"red.png");
                }else{
                    $("#n"+listz[i]).attr("src","../../statics/css/img/"+map[listz[i]]+"green.png");
                }
                if(JSON.stringify(slist).indexOf(JSON.stringify(listz[i])) == -1){
                    $("#s"+listz[i]).attr("src","../../statics/css/img/"+map[listz[i]]+"red.png");
                }else{
                    $("#s"+listz[i]).attr("src","../../statics/css/img/"+map[listz[i]]+"green.png");
                }
            }*/
        }
    });
}
//查询空余车位，左上角表格
function queryParkingSpace(){
    $.get(baseURL + "cw/cwparkingspace/spaceCount", function(r){
        $("#pz").html(r.p);
        $("#pk").html(r.pk);
        $("#psk").html(r.psk);
        $("#pnk").html(r.pnk);
    });
}
//今日车流量统计
function cllCount(){
    $.get(baseURL + "cll/cllvehiclerecord/cllCount", function(r){
        var cllCount= r.cllCount;
        var j=0;
        for (let i = 0; i <=5 ; i++) {
            $('#cll'+i).text(0);
        }
        for (var i = cllCount.length-1; i >=0 ; i--) {
            $('#cll'+j).text(cllCount[i]);
            j++;
        }
    });
}

//今日客流量统计
function kllTodayCount(){
    $.get(baseURL + "rll/rlldayinfo/kllCount", function(r){
        var kllCount= r.kllCount;
        var j=0;
        for (let i = 0; i <=5 ; i++) {
            $('#kll'+i).text(0);
        }
        for (var i = kllCount.length-1; i >=0 ; i--) {
            $('#kll'+j).text(kllCount[i]);
            j++;
        }
    });
}

//今日销售量统计/销售额统计
function xsTodayCount(){
     $.get(baseURL + "jxc/jxcsaleorder/xsTodayCount", function(r){
         var xslTodayCount= r.xslTodayCount;
         var xseTodayCount= r.xseTodayCount;
         var j=0;
         for (var i = xslTodayCount.length-1; i >=0 ; i--) {
             $('#xsl'+j).text(xslTodayCount[i]);
             j++;
         }
         j=0;
         for (var i = xseTodayCount.length-1; i >=0 ; i--) {
             $('#xse'+j).text(xseTodayCount[i]);
             j++;
         }
     });
}

//今日车流量曲线
function cllChart(type) {
    $.get( "../../cll/cllvehiclerecord/cllChart/"+type,function(r){
        $("#scount").html("南区:"+r.southList[2]+"车次");
        $("#ncount").html("北区:"+r.northList[2]+"车次");
        var myChart = echarts.init(document.getElementById('cllChart'));
        var option = {
            tooltip : {
                trigger: 'axis',
                formatter: function(params) { //自定义函数修改折线图给数据加单位
                    var str = '';//声明一个变量用来存储数据
                    str += '<div>'+ params[0].name +'</div>'; //显示首行的函数
                    for(var i=0; i<params.length; i++) { //图显示的数据较多时需要循环数据，这样才可以成功的给多条数据添加单位
                        str += '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:'+params[i].color+';"></span>'+ params[i].seriesName +'</span> : <span>'+ params[i].data+'车次' +'</br>';
                    }
                    return str;
                }
            },
            grid: {
                x: 46,
                y:30,
                x2:32,
                y2:30,
                borderWidth: 0
            },
            legend: {
                data:['南区','北区'],
                textStyle:{
                    color:"#e9ebee"
                },
            },
            calculable : true,
            xAxis : [
                {
                    type : 'category',
                    name:'小时',
                    boundaryGap : false,
                    data : r.southList[0],
                    splitLine: {
                        show: false
                    },
                    axisLabel: {
                        show: true,
                        textStyle: {
                            color: '#a4a7ab'
                        }
                    }
                }
            ],
            yAxis : [
                {
                    type : 'value',
                    name:'总数/车次',
                    splitLine: {
                        show: false
                    },
                    axisLabel: {
                        show: true,
                        textStyle: {
                            color: '#a4a7ab'
                        }
                    }

                }
            ],
            series : [
                {
                    name:'南区',
                    type:'line',
                    //stack: '车次',
                    data:r.southList[1],
                    smooth: true,
                    itemStyle: {
                        normal: {
                            color:"#e15828"
                        }
                    }
                },
                {
                    name:'北区',
                    type:'line',
                    //stack: '车次',
                    smooth: true,
                    data:r.northList[1],
                    itemStyle: {
                        normal: {
                            color:"#2e7cff"
                        }
                    }
                }
            ]
        };
        myChart.setOption(option);
        window.addEventListener("resize",function(){
            myChart.resize();
        });
    })
}
//24小时客流量曲线
function kllChart(type) {

    $.get( "../../rll/rllhourcount/kllChart1/"+type,function(r){

        $("#skllCount").html("南区:"+r.southList[2]+"人次");
        $("#nkllCount").html("北区:"+r.northList[2]+"人次");
        var myChart = echarts.init(document.getElementById('kllChart'));
        var option = {
            tooltip : {
                trigger: 'axis',
                formatter: function(params) { //自定义函数修改折线图给数据加单位
                    var str = '';//声明一个变量用来存储数据
                    str += '<div>'+ params[0].name +'</div>'; //显示首行的函数
                    for(var i=0; i<params.length; i++) { //图显示的数据较多时需要循环数据，这样才可以成功的给多条数据添加单位
                        str += '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:'+params[i].color+';"></span>'+ params[i].seriesName +'</span> : <span>'+ params[i].data+'人次' +'</br>';
                    }
                    return str;
                }
            },
            grid: {
                x: 46,
                y:30,
                x2:32,
                y2:30,
                borderWidth: 0
            },
            legend: {
                data:['南区','北区'],
                textStyle:{
                    color:"#e9ebee"
                },
            },
            calculable : true,
            xAxis : [
                {
                    type : 'category',
                    name:'小时',
                    boundaryGap : false,
                    data : r.southList[0],
                    splitLine: {
                        show: false
                    },
                    axisLabel: {
                        show: true,
                        textStyle: {
                            color: '#a4a7ab'
                        }
                    }
                }
            ],
            yAxis : [
                {
                    type : 'value',
                    name:'客流/人次',
                    splitLine: {
                        show: false
                    },
                    axisLabel: {
                        show: true,
                        textStyle: {
                            color: '#a4a7ab'
                        }
                    }

                }
            ],
            series : [
                {
                    name:'南区',
                    type:'line',
                    //stack: '人次',
                    data:r.southList[1],
                    smooth: true,
                    itemStyle: {
                        normal: {
                            color:"#e15828"
                        }
                    }
                },
                {
                    name:'北区',
                    type:'line',
                    //stack: '人次',
                    smooth: true,
                    data:r.northList[1],
                    itemStyle: {
                        normal: {
                            color:"#2e7cff"
                        }
                    }
                }
            ]
        };
        myChart.setOption(option);
        window.addEventListener("resize",function(){
            myChart.resize();
        });
    })
}
//24小时单品销量排行
function dpSailChart(){
    var detailName=[];
    var detaiAmount=[];
    $.get( "../../jxc/jxcselldetails/detailsRanking",function(r){

        for (var i = r.detailsRanking.length-1; i >=0; i--) {
            detailName.push(r.detailsRanking[i].yvalue);
            detaiAmount.push(r.detailsRanking[i].xvalue);
        }
        var myChart = echarts.init($("#dpSailChart")[0]);
        var option = {
            tooltip : {
                trigger: 'axis',
                formatter: function(params) { //自定义函数修改折线图给数据加单位
                    var str = '';//声明一个变量用来存储数据
                    str += '<div>'+ params[0].name +'</div>'; //显示首行的函数
                    for(var i=0; i<params.length; i++) { //图显示的数据较多时需要循环数据，这样才可以成功的给多条数据添加单位
                        str += '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:'+params[i].color+';"></span>'+ params[i].seriesName +'</span> : <span>'+ params[i].data+'份' +'</br>';
                    }
                    return str;
                },
                axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                    type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            grid: {
                x: 90,
                y:30,
                x2:32,
                y2:40,
                borderWidth: 0
            },
            xAxis:  {
                type: 'value',
                name:'销量/个',
                x:'180',
                splitLine: {
                    show: false
                },
                axisLabel: {
                    show: true,
                    textStyle: {
                        color: '#a4a7ab'
                    }
                }
            },
            yAxis: {
                type: 'category',
                name:'商品名',
                data: detailName,
                splitLine: {
                    show: false
                },
                axisLabel: {
                    show: true,
                    textStyle: {
                        color: '#a4a7ab'
                    }
                }
            },
            series: [
                {
                    name: '销售数量',
                    type: 'bar',
                    stack: '总量',
                    label: {
                        normal: {
                            show: true,
                            position: 'insideRight'
                        }
                    },
                    data: detaiAmount,
                    itemStyle: {
                        normal: {
                            color:"#ff7d0a"
                        }
                    }
                }
            ]
        };
        myChart.setOption(option);
        window.addEventListener("resize",function(){
            myChart.resize();
        });
    })
}
//今日销售趋势
function sailChart(type){
    var name=[];
    var sousale=[];
    var norsale=[];
    var smakmax=null;//南区最大值
    var smaksmall=null;//南区最小值
    var smakmaxx=null;//南区最大值x轴
    var smaksmallx=null;//南区最小值x轴
    var smakmaxy=null;//南区最大值y轴
    var smaksmally=null;//南区最小值y轴
    var nmakmax=null;//北区最大值
    var nmaksmall=null;//北区最小值
    var nmakmaxx=null;//北区最大值x轴
    var nmaksmallx=null;//北区最小值x轴
    var nmakmaxy=null;//北区最大值y轴
    var nmaksmally=null;//北区最小值y轴
    $.get( "../../jxc/jxcsaleorder/hourTodaysale/"+type,function(r){

        smakmax=r.southsale[0].yvue.toFixed(2);
        smaksmall=r.southsale[0].yvue.toFixed(2);
        smakmaxx=r.southsale[0].name;
        smakmaxy=r.southsale[0].yvue.toFixed(2);
        smaksmallx=r.southsale[0].name;
        smaksmally=r.southsale[0].yvue.toFixed(2);

        nmakmax=r.northsale[0].yvue.toFixed(2);
        nmaksmall=r.northsale[0].yvue.toFixed(2);
        nmakmaxx=r.northsale[0].name;
        nmakmaxy=r.northsale[0].yvue.toFixed(2);
        nmaksmallx=r.northsale[0].name;
        nmaksmally=r.northsale[0].yvue.toFixed(2);
        for (var i = r.southsale.length-1; i >=0 ; i--) {
            name.push(r.southsale[i].name+":00");
            sousale.push(r.southsale[i].yvue.toFixed(2));
            if(r.southsale[i].yvue>=smakmax){
                smakmax=r.southsale[i].yvue.toFixed(2);
                smakmaxx=r.southsale[i].name+":00";
                smakmaxy=r.southsale[i].yvue.toFixed(2);
            }else if(r.southsale[i].yvue<=smaksmall){
                smaksmall=r.southsale[i].yvue.toFixed(2);
                smaksmallx=r.southsale[i].name+":00";
                smaksmally=r.southsale[i].yvue.toFixed(2);
            }
        }
        for (var i = r.northsale.length-1; i >=0; i--) {
            norsale.push(r.northsale[i].yvue.toFixed(2));
            if(r.northsale[i].yvue>=nmakmax){
                nmakmax=r.northsale[i].yvue.toFixed(2);
                nmakmaxx=r.northsale[i].name+":00";
                nmakmaxy=r.northsale[i].yvue.toFixed(2);
            }else if(r.northsale[i].yvue<=nmaksmall){
                nmaksmall=r.northsale[i].yvue.toFixed(2);
                nmaksmallx=r.northsale[i].name+":00";
                nmaksmally=r.northsale[i].yvue.toFixed(2);
            }
        }
        var myChart = echarts.init($("#sailChart")[0]);
        option = {
            title : {
                text: '',
                textStyle:{
                    color:"#e9ebee"
                },
                x:'center'
            },
            tooltip : {
                trigger: 'axis',
                formatter: function(params) { //自定义函数修改折线图给数据加单位
                    var str = '';//声明一个变量用来存储数据
                    str += '<div>'+ params[0].name +'</div>'; //显示首行的函数
                    for(var i=0; i<params.length; i++) { //图显示的数据较多时需要循环数据，这样才可以成功的给多条数据添加单位
                        str += '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:'+params[i].color+';"></span>'+ params[i].seriesName +'</span> : <span>'+ params[i].data+'元' +'</br>';
                    }
                    return str;
                }
            },
            legend: {
                orient : 'vertical',
                x : 'left',
                data:['南区','北区'],
                textStyle:{
                    color:"#e9ebee"

                },
            },

            calculable : false,
            xAxis : [
                {
                    type : 'category',
                    name:'小时',
                    splitLine:{show: false},
                    axisLabel : {
                        formatter: '{value} ',
                        textStyle: {
                            color: '#a4a7ab',
                            align: 'right'
                        }
                    },
                    data : name,
                }
            ],
            yAxis : [
                {
                    type : 'value',
                    name:'销售额/元',
                    splitLine:{show: false},
                    axisLabel : {
                        formatter: '{value} ',
                        textStyle: {
                            color: '#a4a7ab',
                            align: 'right'
                        }
                    }
                }
            ],
            grid:{
                borderWidth:0
            },
            series : [
                {
                    name:'南区',
                    type:'bar',
                    data:sousale,
                    itemStyle: {
                        normal: {
                            color: '#2481ff'
                        }
                    },
                    markPoint : {
                        data : [
                            {name : '最高', value : smakmax, xAxis: smakmaxx, yAxis: smakmaxy, symbolSize:18},
                            {name : '最低', value : smaksmall, xAxis: smaksmallx, yAxis: smaksmally}
                        ]
                    },
                    markLine : {
                        data : [
                            {type : 'average', name: '平均值'}
                        ]
                    }
                },
                {
                    name:'北区',
                    type:'bar',
                    data:norsale,
                    itemStyle: {
                        normal: {
                            color: '#1afffd'
                        }
                    },

                    markPoint : {
                        data : [
                            {name : '最高', value : nmakmax, xAxis: nmakmaxx, yAxis: nmakmaxy, symbolSize:18},
                            {name : '最低', value : nmaksmall, xAxis: nmaksmallx, yAxis: nmaksmally}
                        ]
                    },
                    markLine : {
                        data : [
                            {type : 'average', name : '平均值'}
                        ]
                    }
                }
            ]
        };
        myChart.setOption(option);
        window.addEventListener("resize",function(){
            myChart.resize();
        });
    })
}


//24小时南区北区销售统计
function nbSailChart(type){
    //南区销量
    $(function () {
        //var southName = [];
        //var northName = [];
        var southValue = [];
        var northValue = [];
        var clor = ['#1afffd', '#2e7cff', '#ffcb89', '#005ea1', '#0ad5ff','#990099','#FF0000','#009900','#FF00FF','#FFC0CB','#B0C4DE','#C0C0C0','#8B4513','#FFE4B5','#808000','#7CFC00','#40E0D0','#BA55D3','#F0FFFF','#E6E6FA','#5F9EA0'];
        $.get("../../jxc/jxcsaleorder/hourTodaySalesvolume/"+type, function (r) {
            var southList=r.southvolume;
            var northList=r.northvolume;
            for (let i = 0; i < southList.length; i++) {
                southValue.push({
                    value: southList[i].totalAmount, name: southList[i].shopName, itemStyle: {
                       /* normal: {
                            color: clor[i]
                        }*/
                    }
                });
            }
            for (let i = 0; i < northList.length; i++) {
                northValue.push({
                    value: northList[i].totalAmount, name: northList[i].shopName, itemStyle: {
                       /* normal: {
                            color: clor[i]
                        }*/
                    }
                });
            }
            var myChart = echarts.init($("#nqSailChart")[0]);
            option = {
                tooltip : {
                    trigger: 'item',
                    formatter: "{a}<br/>{b}:{c}"+"元"+"({d}%)",
                    position: [40, 150]
                },
                title: {
                    text: '南区',
                    textStyle: {
                        color: "#e9ebee"

                    },
                    x: 'center'

                },
                calculable: false,
                series: [
                    {
                        name: '销售额',
                        type: 'pie',
                        radius: '55%',
                        center: ['50%', '60%'],
                        data: southValue
                    }
                ]
            };
            myChart.setOption(option);
            window.addEventListener("resize",function(){
                myChart.resize();
            });
            var myChart1 = echarts.init($("#bqSailChart")[0]);
            option = {
                tooltip : {
                    trigger: 'item',
                    formatter: "{a}<br/>{b}:{c}"+"元"+"({d}%)",
                    position: [40, 150]
                },
                title: {
                    text: '北区',
                    textStyle: {
                        color: "#e9ebee"

                    },
                    x: 'center'

                },
                calculable: false,
                series: [
                    {
                        name: '销售额',
                        type: 'pie',
                        radius: '55%',
                        center: ['50%', '60%'],
                        data: northValue
                    }
                ]
            };
            myChart1.setOption(option);
            window.addEventListener("resize",function(){
                myChart1.resize();
            });
        });
    });
}

/****************第一标签方法结束*************************/

/****************第2标签方法开始*************************/
//1分钟定时任务
function index1one() {
    carInOut();
}
//5分钟定时任务
function index1five() {

}
function ckllCount() {
    $.get(baseURL + "cll/cllvehiclerecord/cllCount?type="+zytype+"&time="+zytime, function(r){
        var cllCount= r.cllCount;
        $("#cllz").html(cllCount+"车次")
        $("#clln").html(r.southCount+"车次")
        $("#cllb").html(r.northCount+"车次")
    })
    $.get(baseURL + "rll/rlldayinfo/kllCount?type="+zytype+"&time="+zytime, function(r){
        var kllCount= r.kllCount;
        $("#kllz").html(kllCount+"人次")
        $("#klln").html(r.southCount+"人次")
        $("#kllb").html(r.northCount+"人次")

        var area=["南区","北区"];
        var value=[{value:r.southCount,name:"南区"},{value:r.northCount,name:"北区"}];

        var myChart = echarts.init(document.getElementById('peoplecount'));
        var option = {
            tooltip : {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c}"+"人次"+" ({d}%)",
                position: [65, 280]
            },
            legend: {
                x: 'center',
                y: 16,
                data:area,
                textStyle:{
                    color:"#e9ebee"
                }
            },
            series : [
                {
                    name: '客流统计',
                    type: 'pie',
                    radius : '50%',
                    center: ['50%', '60%'],
                    data:value,
                    itemStyle: {
                        emphasis: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    }
                }
            ]
        };
        myChart.setOption(option);
        window.addEventListener("resize",function(){
            myChart.resize();
        });
    });
}
//车流量统计
function carFlowChart() {
    var xname=null;
    if(zytype == "0"){
        xname="小时";
    }else if(zytype == "1"){
        xname="日期";
    }
    $.get("../../cll/cllvehiclerecord/carflow?type="+zytype+"&time="+zytime, function (r) {
        /*console.log(1)
        console.log(r)*/
        souinvalue=r.southinlist;
        sououtvalue=r.southoutlist;
        norinvalue=r.northlist;
        noroutvalue=r.northoutlist;
        var myChart = echarts.init($("#carFlowChart")[0]);
        var option = {
            tooltip : {
                trigger: 'axis',
                formatter: function(params) { //自定义函数修改折线图给数据加单位
                    var str = '';//声明一个变量用来存储数据
                    str += '<div>'+ params[0].name +'</div>'; //显示首行的函数
                    for(var i=0; i<params.length; i++) { //图显示的数据较多时需要循环数据，这样才可以成功的给多条数据添加单位
                        str += '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:'+params[i].color+';"></span>'+ params[i].seriesName +'</span> : <span>'+ params[i].data+'车次' +'</br>';
                    }
                    return str;
                }
            },
            legend: {
                x: 'center',
                data: ["南区入口","南区出口","北区入口","北区出口"],
                textStyle:{
                    color:"#e9ebee"
                }
            },
            grid: {
                x: 46,
                y:30,
                x2:32,
                y2:40,
                borderWidth: 0
            },
            calculable : true,
            xAxis : [
                {
                    type : 'category',
                    name:xname,
                    boundaryGap : false,
                    data :r.southinlist[0],
                    splitLine: {
                        show: false
                    },
                    axisLabel: {
                        show: true,
                        textStyle: {
                            color: '#a4a7ab'
                        }
                    }
                }
            ],
            yAxis : [
                {
                    type : 'value',
                    name :"总数/车次",
                    splitLine: {
                        show: false
                    },
                    axisLabel: {
                        show: true,
                        textStyle: {
                            color: '#a4a7ab'
                        }
                    }

                }
            ],
            series : [
                {
                    name:"南区入口",
                    type:'line',
                    //stack: '辆',
                    data:r.southinlist[1],
                    smooth: true,
                    itemStyle: {
                        normal: {
                            //color:"#45c0ff"
                            color:"red"
                        }
                    }
                },
                {
                    name:"南区出口",
                    type:'line',
                    //stack: '辆',
                    data:r.southoutlist[1],
                    smooth: true,
                    itemStyle: {
                        normal: {
                            color:"#0ad5ff"
                        }
                    }
                },
                {
                    name:"北区入口",
                    type:'line',
                    //stack: '辆',
                    data:r.northlist[1],
                    smooth: true,
                    itemStyle: {
                        normal: {
                            color:"#005ea1"
                        }
                    }
                },
                {
                    name:"北区出口",
                    type:'line',
                    //stack: '辆',
                    data:r.northoutlist[1],
                    smooth: true,
                    itemStyle: {
                        normal: {
                            color:"#ffcb89"
                        }
                    }
                }
            ]
        };
        myChart.setOption(option);
        window.addEventListener("resize",function(){
            myChart.resize();
        });
    })
}
//车辆归属地统计
function carfrom() {
    var areaname=[];
    var areavalue=[];
    $.get("../../cll/cllvehiclerecord/carownership?type="+zytype+"&time="+zytime, function (r) {
        for (var i = 0; i <r.carownership.length ; i++) {
            areaname.push(r.carownership[i].areaname);
            areavalue.push(r.carownership[i].yvalie);
        }
        var myChart = echarts.init($("#carfrom")[0]);
        var option = {
            tooltip : {
                trigger: 'axis',
                formatter: function(params) { //自定义函数修改折线图给数据加单位
                    var str = '';//声明一个变量用来存储数据
                    str += '<div>'+ params[0].name +'</div>'; //显示首行的函数
                    for(var i=0; i<params.length; i++) { //图显示的数据较多时需要循环数据，这样才可以成功的给多条数据添加单位
                        str += '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:'+params[i].color+';"></span>'+ params[i].seriesName +'</span> : <span>'+ params[i].data+'辆' +'</br>';
                    }
                    return str;
                },
                axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                    type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            grid: {
                x: 50,
                y:20,
                x2:22,
                y2:40,
                borderWidth: 0
            },
            calculable : true,
            xAxis : [
                {
                    type : 'category',
                    name:'省份',
                    data:areaname,
                    splitLine: {
                        show: false
                    },
                    axisLabel: {
                        show: true,
                        textStyle: {
                            color: '#a4a7ab',
                            align: 'center'
                        }
                    }
                }
            ],
            yAxis : [
                {
                    type : 'value',
                    name:'总数/车次',
                    splitLine: {
                        show: false
                    },
                    axisLabel: {
                        show: true,
                        textStyle: {
                            color: '#a4a7ab'
                        }
                    }
                }
            ],
            series : [
                {
                    name:'数量（辆）',
                    type:'bar',
                    /*barWidth:'30',*/
                    data:areavalue,
                    itemStyle: {
                        normal: {
                            label: {
                                show: true, //开启显示
                                position: 'top', //在上方显示
                                textStyle: { //数值样式
                                    color: 'white'
                                    /*fontSize: 16*/
                                }
                            },
                            color:"#1afffd"
                        }
                    }

                }
            ]
        };
        myChart.setOption(option);
        window.addEventListener("resize",function(){
            myChart.resize();
        });
    })
}
function carGroupChart() {
    var clor = ['#1afffd', '#2e7cff', '#ffcb89', '#005ea1', '#0ad5ff','#990099','#FF0000','#009900','#FF00FF','#FFC0CB','#B0C4DE','#C0C0C0','#8B4513','#FFE4B5','#808000','#7CFC00','#40E0D0','#BA55D3','#F0FFFF','#E6E6FA','#5F9EA0'];
    var type=24;
    // var cartype=[];
    var carvalue=[];
    $.get("../../cll/cllvehiclerecord/cartype?type="+zytype+"&time="+zytime, function (r) {
        var list=r.cartypelist;
        for (var i = 0; i <list.length ; i++) {
            //cartype.push(list[i].areaname);
            carvalue.push({
                value:list[i].yvalie,name:list[i].areaname,itemStyle:{
                    normal:{
                        color:clor[i]
                    }
                }
            });
        }
        var myChart = echarts.init($("#carGroupChart")[0]);
        var option = {
            tooltip : {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c}"+"车次"+" ({d}%)",
                position: [70, 280]
            },
            /*legend: {
                x: 'center',
                y:"16",
                data:cartype,
                textStyle:{
                    color:"#e9ebee"
                }
            },*/
            series : [
                {
                    itemStyle: {
                        normal: {
                            label: {
                                show: false
                            },
                            labelLine: {
                                show: false
                            }
                        }
                    },
                    name: '',
                    type: 'pie',
                    radius : '50%',
                    center: ['53%', '60%'],
                    data:carvalue,
                    itemStyle: {
                        emphasis: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    }
                }
            ]
        };
        myChart.setOption(option);
        window.addEventListener("resize",function(){
            myChart.resize();
        });
    });
}
//车辆通过列表
function carInOut() {
    $.get("../../cll/cllvehiclerecord/carinout", function (r) {
        $("#carinout").empty();
        //var info="<thead><tr><th style='width: 18%'>车牌号</th><th>车型</th><th>归属地</th><th>时间</th><th>详情</th></tr></thead><tbody>";
        var info="";
        var list=r.carinoutlist;
        for (var i = 0; i <list.length ; i++) {
            if (list[i].monitoringName.indexOf("入口")!=-1){
                info +="<tr class='carIn'><td>"+list[i].plateNo+"</td><td>"+list[i].vehicleType+"</td><td>"+list[i].areaname+"</td><td>"+list[i].monitoringName+"</td><td>"+list[i].crossTime+"</td></tr>";
            }else {
                info +="<tr class='carOut'><td>"+list[i].plateNo+"</td><td>"+list[i].vehicleType+"</td><td>"+list[i].areaname+"</td><td>"+list[i].monitoringName+"</td><td>"+list[i].crossTime+"</td></tr>";
            }
        }
        info +="</tbody>"
        $("#carinout").append(info);
    })
}
//客流量对比饼图
function peopleCount() {
   /* var area=[];
    var value=[];
    var clor = ['#1afffd', '#2e7cff', '#ffcb89', '#005ea1', '#0ad5ff','#45c0ff','#990099','#FF0000','#009900','#FF00FF','#FFC0CB','#B0C4DE','#C0C0C0','#8B4513','#FFE4B5','#808000','#7CFC00','#40E0D0','#BA55D3','#F0FFFF','#E6E6FA','#5F9EA0'];
    /!* {value:335, name:'监测一',
            itemStyle:{
                normal:{
                    color:"#1afffd"
                }
            }},*!/
    $.get( "../../rll/rllhourcount/peoplecount?type="+zytype+"&time="+zytime,function(r){
        var list=r.peoplecountlist;
        for (var i = 0; i <list.length ; i++) {
            area.push(list[i].area);
            value.push(
                {
                    value:list[i].count,name:list[i].area,
                    itemStyle:{
                        normal:{
                            color:clor[i]
                        }
                    }
                }
            );
        }
        var myChart = echarts.init(document.getElementById('peoplecount'));
        var option = {
            tooltip : {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c} ({d}%)",
                position: [65, 280]
            },
            legend: {
                x: 'center',
                y: 16,
                data:area,
                textStyle:{
                    color:"#e9ebee"
                }
            },
            series : [
                {
                    name: '客流统计',
                    type: 'pie',
                    radius : '50%',
                    center: ['50%', '60%'],
                    data:value,
                    itemStyle: {
                        emphasis: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    }
                }
            ]
        };
        myChart.setOption(option);
        window.addEventListener("resize",function(){
            myChart.resize();
        });
    })*/
}
//客流量统计
function peopleFlowChart() {
    var xname=null;
    if(zytype == "0"){
        xname="小时";
    }else if(zytype == "1"){
        xname="日期";
    }
    var xvalue=[];
    var syvalue=[];
    var nyvalue=[];
    var scount=0;
    var ncount=0;
    $.get( "../../rll/rllhourcount/kllChartbytime?type="+zytype+"&time="+zytime,function(r){
        var time=r.time;
        var skll=r.skll;
        var nkll=r.nkll;
        var timeArray=[];
        /*var skllArray=[];
        var nkllArray=[];*/
        var skllCount=0;
        var nkllCount=0;

        /*//处理时间
        for (var i = 0; i <time.length ; i++) {
            var t1=time[i].split(" ");
            var t2=t1[1].split(":");
            if(Number(t2[0])+1==24){
                time[i]="0:00"
            }else {
                time[i]=(Number(t2[0])+1)+":00"
            }
            skllCount+=skll[i];
            nkllCount+=nkll[i];
        }*/

        /*$("#skllCount").html("南区:"+skllCount+"人次");
        $("#nkllCount").html("北区:"+nkllCount+"人次");*/
        var myChart = echarts.init(document.getElementById('peopleflow'));
        var option = {
            tooltip : {
                trigger: 'axis',
                formatter: function(params) { //自定义函数修改折线图给数据加单位
                    var str = '';//声明一个变量用来存储数据
                    str += '<div>'+ params[0].name +'</div>'; //显示首行的函数
                    for(var i=0; i<params.length; i++) { //图显示的数据较多时需要循环数据，这样才可以成功的给多条数据添加单位
                        str += '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:'+params[i].color+';"></span>'+ params[i].seriesName +'</span> : <span>'+ params[i].data+'人次' +'</br>';
                    }
                    return str;
                }
            },
            grid: {
                x: 46,
                y:30,
                x2:32,
                y2:30,
                borderWidth: 0
            },
            legend: {
                data:['南区','北区'],
                textStyle:{
                    color:"#e9ebee"
                },
            },
            calculable : true,
            xAxis : [
                {
                    type : 'category',
                    name:xname,
                    boundaryGap : false,
                    data : time,
                    splitLine: {
                        show: false
                    },
                    axisLabel: {
                        show: true,
                        textStyle: {
                            color: '#a4a7ab'
                        }
                    }
                }
            ],
            yAxis : [
                {
                    type : 'value',
                    name:'总数/人次',
                    splitLine: {
                        show: false
                    },
                    axisLabel: {
                        show: true,
                        textStyle: {
                            color: '#a4a7ab'
                        }
                    }

                }
            ],
            series : [
                {
                    name:'南区',
                    type:'line',
                    //stack: '人次',
                    data:skll,
                    smooth: true,
                    itemStyle: {
                        normal: {
                            color:"#e15828"
                        }
                    }
                },
                {
                    name:'北区',
                    type:'line',
                   // stack: '人次',
                    smooth: true,
                    data:nkll,
                    itemStyle: {
                        normal: {
                            color:"#2e7cff"
                        }
                    }
                }
            ]
        };
        myChart.setOption(option);
        window.addEventListener("resize",function(){
            myChart.resize();
        });
    })
}
//客流车流销售额对比
function contrastChart() {
    var xname=null;
    if(zytype == "0"){
        xname="小时";
    }else if(zytype == "1"){
        xname="日期";
    }
    var timeArray=[];
    var salelist=[];
    var clllist;
    var rlllist;
    $.get( "../../jxc/jxcsaleorder/salecllrll?type="+zytype+"&time="+zytime,function(r){
        var maps=r.salecllrlllist;
        timeArray=maps["销售额"][0];
       // salelist=maps["销售额"][1];
        for (let i = 0; i <maps["销售额"][1].length ; i++) {
            salelist.push(maps["销售额"][1][i].toFixed(2));
        }
        clllist=maps["车流量"];
        rlllist=maps["客流量"];
        var myChart = echarts.init($("#contrastChart")[0]);
        var option = {
            tooltip : {
                trigger: 'axis',
                formatter: function(params) { //自定义函数修改折线图给数据加单位
                    var str = '';//声明一个变量用来存储数据
                    str += '<div>'+ params[0].name +'</div>'; //显示首行的函数
                    str += '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:'+params[0].color+';"></span>'+ params[0].seriesName +'</span> : <span>'+ params[0].data+'元' +'</br>';
                    str += '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:'+params[1].color+';"></span>'+ params[1].seriesName +'</span> : <span>'+ params[1].data+'车次' +'</br>';
                    str += '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:'+params[2].color+';"></span>'+ params[2].seriesName +'</span> : <span>'+ params[2].data+'人次' +'</br>';
                    return str;
                }
            },
            grid: {
                x: 46,
                y:30,
                x2:32,
                y2:40,
                borderWidth: 0
            },
            calculable : true,
            legend: {
                x: 'center',
                data: ["销售金额","车流量","客流量"],
                textStyle:{
                    color:"#e9ebee"
                }
            },
            xAxis : [
                {
                    type : 'category',
                    name:xname,
                    boundaryGap : false,
                    data :timeArray,
                    splitLine: {
                        show: false
                    },
                    axisLabel: {
                        show: true,
                        textStyle: {
                            color: '#a4a7ab'
                        }
                    }
                }
            ],
            yAxis : [
                {
                    type: 'value',
                    name: '销售金额/元',
                    splitLine: {
                        show: false
                    },
                    interval: 50,
                    axisLabel: {
                        show: true,
                        textStyle: {
                            color: '#a4a7ab'
                        },
                    }
                },
                {
                    type: 'value',
                    name: '流量/次',
                    splitLine: {
                        show:false
                    },
                    interval: 5,
                    axisLabel: {
                        show: true,
                        textStyle: {
                            color: '#a4a7ab'
                        },
                    }
                }
            ],
            series : [
                {
                    name:'销售金额',
                    type:'line',
                    data:salelist,
                    smooth: true,
                    itemStyle: {
                        normal: {
                            color:"#e15828"
                        }
                    }
                },
                {
                    name:'车流量',
                    type:'line',
                    yAxisIndex: 1,
                    data: clllist,
                    smooth: true,
                    itemStyle: {
                        normal: {
                            color:"#2e7cff"
                        }
                    }
                },
                {
                    name:'客流量',
                    type:'line',
                    yAxisIndex: 1,
                    data:rlllist,
                    smooth: true,
                    itemStyle: {
                        normal: {
                            color:"#e9a832"
                        }
                    }
                }
            ]
        };
        myChart.setOption(option);
        window.addEventListener("resize",function(){
            myChart.resize();
        });
    })
}
/****************第2标签方法结束*************************/
/****************第3标签方法开始*************************/

//5分钟定时任务
function index2five() {
    realTimeOrder();
}
function sailCount() {
    var southValue=0;
    var northValue=0;
    $.get( "../../jxc/jxcsaleorder/sailCount?type="+zytype+"&time="+zytime,function(r){

        $("#totalz").html((r.southCount+r.northCount)+"元");
        $("#stotalz").html(r.southCount+"元");
        $("#ntotalz").html(r.northCount+"元");
    })
}

//单品销量排行
function dpSailChart1() {
    var detailName=[];
    var detaiAmount=[];
    $.get( "../../jxc/jxcselldetails/detailsbytime?type="+zytype+"&time="+zytime,function(r){

        for (var i = r.detailsRanking.length-1; i >=0; i--) {
            detailName.push(r.detailsRanking[i].yvalue);
            detaiAmount.push(r.detailsRanking[i].xvalue);
        }
        var myChart = echarts.init($("#paihang1")[0]);
        var option = {
            tooltip : {
                trigger: 'axis',
                formatter: function(params) { //自定义函数修改折线图给数据加单位
                    var str = '';//声明一个变量用来存储数据
                    str += '<div>'+ params[0].name +'</div>'; //显示首行的函数
                    for(var i=0; i<params.length; i++) { //图显示的数据较多时需要循环数据，这样才可以成功的给多条数据添加单位
                        str += '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:'+params[i].color+';"></span>'+ params[i].seriesName +'</span> : <span>'+ params[i].data+'份' +'</br>';
                    }
                    return str;
                },
                axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                    type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            grid: {
                x: 90,
                y:30,
                x2:32,
                y2:40,
                borderWidth: 0
            },
            xAxis:  {
                type: 'value',
                name:'销量/个',
                x:'180',
                splitLine: {
                    show: false
                },
                axisLabel: {
                    show: true,
                    textStyle: {
                        color: '#a4a7ab'
                    }
                }
            },
            yAxis: {
                type: 'category',
                name:'商品名称',
                data: detailName,
                splitLine: {
                    show: false
                },
                axisLabel: {
                    show: true,
                    textStyle: {
                        color: '#a4a7ab'
                    }
                }
            },
            series: [
                {
                    name: '销售数量',
                    type: 'bar',
                    stack: '总量',
                    label: {
                        normal: {
                            show: true,
                            position: 'insideRight'
                        }
                    },
                    data: detaiAmount,
                    itemStyle: {
                        normal: {
                            color:"#ff7d0a"
                        }
                    }
                }
            ]
        };
        myChart.setOption(option);
        window.addEventListener("resize",function(){
            myChart.resize();
        });
    })
}
//销售趋势
function salesCurve() {
    var xname=null;
    if(zytype == "0"){
        xname="小时";
    }else if(zytype == "1"){
        xname="日期";
    }
    var name=[];
    var sousale=[];
    var norsale=[];
    var smakmax=null;//南区最大值
    var smaksmall=null;//南区最小值
    var smakmaxx=null;//南区最大值x轴
    var smaksmallx=null;//南区最小值x轴
    var smakmaxy=null;//南区最大值y轴
    var smaksmally=null;//南区最小值y轴
    var nmakmax=null;//北区最大值
    var nmaksmall=null;//北区最小值
    var nmakmaxx=null;//北区最大值x轴
    var nmaksmallx=null;//北区最小值x轴
    var nmakmaxy=null;//北区最大值y轴
    var nmaksmally=null;//北区最小值y轴
    $.get( "../../jxc/jxcsaleorder/salebytime?type="+zytype+"&time="+zytime,function(r){
         name=r.southsale[0];
         //sousale=r.southsale[1];//南区集合
        for (let i = 0; i <r.southsale[1].length; i++) {
            sousale.push(r.southsale[1][i].toFixed(2));
        }
        // norsale=r.northsale[1];//北区集合
        for (let i = 0; i <r.northsale[1].length; i++) {
            norsale.push(r.northsale[1][i].toFixed(2));
        }
        smakmax=sousale[0];
        smaksmall=sousale[0];
        smakmaxx=name[0];
        smaksmallx=name[0];
        smakmaxy=sousale[0];
        smaksmally=sousale[0];

        nmakmax=norsale[0];
        nmaksmall=norsale[0];
        nmakmaxx=name[0];
        nmakmaxy=norsale[0];
        nmaksmallx=name[0];
        nmaksmally=norsale[0];
        for (var i = 0; i <r.southsale[1].length ; i++) {
            if(r.southsale[1][i] >=smakmax){
                smakmaxx=r.southsale[0][i];
                smakmax=r.southsale[1][i].toFixed(2);
                smakmaxy=r.southsale[1][i].toFixed(2);
            }else if(r.southsale[1][i] <=smaksmall){
                smaksmallx=r.southsale[0][i];
                smaksmall=r.southsale[1][i].toFixed(2);
                smaksmally=r.southsale[1][i].toFixed(2);
            }
        }
        for (var i = 0; i <r.northsale[1].length ; i++) {
            if(r.northsale[1][i] >= nmakmax){
                nmakmaxx=r.northsale[0][i];
                nmakmax=r.northsale[1][i].toFixed(2);
                nmakmaxy=r.northsale[1][i].toFixed(2);
            }else if(r.northsale[1][i] <= nmaksmall){
                nmaksmallx=r.northsale[0][i];
                nmaksmall=r.northsale[1][i].toFixed(2);
                nmaksmally=r.northsale[1][i].toFixed(2);
            }
        }
        var myChart = echarts.init($("#salesCurve")[0]);
        option = {
            title : {
                text: '',
                textStyle:{
                    color:"#e9ebee"
                },
                x:'center'
            },
            tooltip : {
                trigger: 'axis',
                formatter: function(params) { //自定义函数修改折线图给数据加单位
                    var str = '';//声明一个变量用来存储数据
                    str += '<div>'+ params[0].name +'</div>'; //显示首行的函数
                    for(var i=0; i<params.length; i++) { //图显示的数据较多时需要循环数据，这样才可以成功的给多条数据添加单位
                        str += '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:'+params[i].color+';"></span>'+ params[i].seriesName +'</span> : <span>'+ params[i].data+'元' +'</br>';
                    }
                    return str;
                }
            },
            legend: {
                orient : 'vertical',
                x : 'left',
                data:['南区','北区'],
                textStyle:{
                    color:"#e9ebee"

                },
            },

            calculable : false,
            xAxis : [
                {
                    type : 'category',
                    name:xname,
                    splitLine:{show: false},
                    axisLabel : {
                        formatter: '{value} ',
                        textStyle: {
                            color: '#a4a7ab',
                            align: 'right'
                        }
                    },
                    data : name,
                }
            ],
            yAxis : [
                {
                    type : 'value',
                    name:'销售额/元',
                    splitLine:{show: false},
                    axisLabel : {
                        formatter: '{value} ',
                        textStyle: {
                            color: '#a4a7ab',
                            align: 'right'
                        }
                    }
                }
            ],
            grid:{
                borderWidth:0
            },
            series : [
                {
                    name:'南区',
                    type:'bar',
                    data:sousale,
                    itemStyle: {
                        normal: {
                            color: '#2481ff'
                        }
                    },
                    markPoint : {
                        data : [
                            {name : '最高', value : smakmax, xAxis: smakmaxx, yAxis: smakmaxy, symbolSize:18},
                            {name : '最低', value : smaksmall, xAxis: smaksmallx, yAxis: smaksmally}
                        ]
                    },
                    markLine : {
                        data : [
                            {type : 'average', name: '平均值'}
                        ]
                    }
                },
                {
                    name:'北区',
                    type:'bar',
                    data:norsale,
                    itemStyle: {
                        normal: {
                            color: '#1afffd'
                        }
                    },

                    markPoint : {
                        data : [
                            {name : '最高', value : nmakmax, xAxis: nmakmaxx, yAxis: nmakmaxy, symbolSize:18},
                            {name : '最低', value : nmaksmall, xAxis: nmaksmallx, yAxis: nmaksmally}
                        ]
                    },
                    markLine : {
                        data : [
                            {type : 'average', name : '平均值'}
                        ]
                    }
                }
            ]
        };
        myChart.setOption(option);
        window.addEventListener("resize",function(){
            myChart.resize();
        });
    })
}

function allAly() { /*呵呵*/
    var southValue = [];
    var northValue = [];
    var clor = ['#1afffd', '#2e7cff', '#ffcb89', '#005ea1', '#0ad5ff','#990099','#FF0000','#009900','#FF00FF','#FFC0CB','#B0C4DE','#C0C0C0','#8B4513','#FFE4B5','#808000','#7CFC00','#40E0D0','#BA55D3','#F0FFFF','#E6E6FA','#5F9EA0'];
    $.get("../../jxc/jxcsaleorder/orderbytime?type="+zytype+"&time="+zytime, function (r) {
        var southList=r.southvolume;
        var northList=r.northvolume;
        for (let i = 0; i < southList.length; i++) {
            southValue.push({
                value: southList[i].totalAmount, name: southList[i].shopName, itemStyle: {
                    /* normal: {
                         color: clor[i]
                     }*/
                }
            });
        }
        for (let i = 0; i < northList.length; i++) {
            northValue.push({
                value: northList[i].totalAmount, name: northList[i].shopName, itemStyle: {
                    /* normal: {
                         color: clor[i]
                     }*/
                }
            });
        }
        var myChart = echarts.init($("#allAly01")[0]);
        option = {
            tooltip : {
                trigger: 'item',
                formatter: "{a}<br/>{b}:{c}"+"元"+"({d}%)",
                position:[130,230]
            },
            title: {
                text: '南区',
                textStyle: {
                    color: "#e9ebee"

                },
                x: 'center'

            },
            calculable: false,
            series: [
                {
                    name: '销售额',
                    type: 'pie',
                    radius: '55%',
                    center: ['50%', '60%'],
                    data: southValue
                }
            ]
        };
        myChart.setOption(option);
        window.addEventListener("resize",function(){
            myChart.resize();
        });
        var myChart1 = echarts.init($("#allAly02")[0]);
        option = {
            tooltip : {
                trigger: 'item',
                formatter: "{a}<br/>{b}:{c}"+"元"+"({d}%)",
                position:[130,230]
            },
            title: {
                text: '北区',
                textStyle: {
                    color: "#e9ebee"

                },
                x: 'center'

            },
            calculable: false,
            series: [
                {
                    name: '销售额',
                    type: 'pie',
                    radius: '55%',
                    center: ['50%', '60%'],
                    data: northValue
                }
            ]
        };
        myChart1.setOption(option);
        window.addEventListener("resize",function(){
            myChart1.resize();
        });
    });
}
function realTimeOrder() {
    var info="";
    $.get( "../../jxc/jxcsaleorder/realtimeorder",function(r){
        var list=r.realtimeorder;
        var infoId
        for (var i = 0; i <list.length ; i++) {
            $("#realtimed").empty()
            if(i==0){
                infoId=list[i].sellMasterCode;
            }
            info +="<div class='message_scroll1'><div class='scroll_top'>" +
                "<span class='scroll_level' style='width: 25%'>"+list[i].sellMasterDate+"</span>" +
                "<span class='scroll_level' style='width: 10%'>"+list[i].name+"</span>" +
                "<span class='scroll_level' style='width: 20%'>"+list[i].shopName+"</span>" +
                "<span class='scroll_level' style='width: 15%'>数量:"+list[i].totalCount+"</span>" +
                "<span class='scroll_level' style='width: 18%'>总金额:"+list[i].totalAmount+"元</span>" +
                "<span id="+list[i].sellMasterCode+" onclick='querydetail(this)' class='scroll_level' style='width: 5%'><a>详情</a></span>" +
                /* "<span class='scroll_level' style='float: right'><a style='color: #e9a832;font-size: 12px'>银监回放</a></span>" +*/
                "</div></div>";


        }
        $("#realtimed").append(info)
        $("#"+infoId).click();
    })
}

//实时订单详情点击事件
function querydetail(data){
    var orderCode=$(data).attr('id');
    $(".order").removeClass("order");
    $(data).parent().addClass("order");
    var info="<tr><td class='font04'>商品名称</td><td class='font04'>数量</td><td class='font04'>单价</td><td class='font04'>优惠</td><td class='font04'>总价</td></tr>>";
    $.get( "../../jxc/jxcselldetails/querydetail?id="+orderCode,function(r){

        $("#detaillist").empty();
        var detaillist=r.querydetail;
        for (var i = 0; i <detaillist.length ; i++) {
            info +="<tr><td>"+detaillist[i].commodityName+"</td><td>"+detaillist[i].sellCount+"</td><td>"+detaillist[i].price+"元</td><td>"+detaillist[i].discount+"元</td><td>"+detaillist[i].sellAmount+"元</td></tr>";
        }
        $("#detaillist").append(info);
    })
}
//客流销售额趋势
function kdj() {
    var xname=null;
    if(zytype == "0"){
        xname="小时";
    }else if(zytype == "1"){
        xname="日期";
    }
    var timeArray=[];
    var salelist=[];
    var rlllist;
    $.get( "../../jxc/jxcsaleorder/salerll?type="+zytype+"&time="+zytime,function(r){
        var maps=r.salecllrlllist;
        timeArray=maps["销售额"][0];
        //salelist=maps["销售额"][1];
        for (let i = 0; i <maps["销售额"][1].length ; i++) {
            salelist.push(maps["销售额"][1][i].toFixed(2));
        }
        rlllist=maps["客流量"];
        /*for (var key in maps) {
            thname.push(key);
            if(key =="销售额"){
                for (var i = maps[key].length-1; i >=0 ; i--) {
                    timeArray.push(maps[key][i].name);
                    salelist.push(maps[key][i].yvalue)
                }
            }else if(key =="客流量"){
                for (var i = maps[key].length-1; i >=0 ; i--) {
                    rlllist.push(maps[key][i].yvalue)
                }
            }
        }*/
        var myChart = echarts.init(document.getElementById('salesCurve1'));
        var option = {
            tooltip : {
                trigger: 'axis',
                formatter: function(params) { //自定义函数修改折线图给数据加单位
                    var str = '';//声明一个变量用来存储数据
                    str += '<div>'+ params[0].name +'</div>'; //显示首行的函数
                    str += '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:'+params[0].color+';"></span>'+ params[0].seriesName +'</span> : <span>'+ params[0].data+'元' +'</br>';
                    str += '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:'+params[1].color+';"></span>'+ params[1].seriesName +'</span> : <span>'+ params[1].data+'人次' +'</br>';
                    return str;
                }
            },
            grid: {
                x: 46,
                y:30,
                x2:32,
                y2:60,
                borderWidth: 0
            },
            calculable : true,
            legend: {
                x: 'center',
                data: ["销售金额","客流量"],
                textStyle:{
                    color:"#e9ebee"
                }
            },
            xAxis : [
                {
                    type : 'category',
                    name:xname,
                    boundaryGap : false,
                    data :timeArray,
                    splitLine: {
                        show: false
                    },
                    axisLabel: {
                        show: true,
                        textStyle: {
                            color: '#a4a7ab'
                        }
                    }
                }
            ],
            yAxis : [
                {
                    type: 'value',
                    name: '销售金额/元',
                    splitLine: {
                        show: false
                    },
                    interval: 50,
                    axisLabel: {
                        show: true,
                        textStyle: {
                            color: '#a4a7ab'
                        },
                    }
                },
                {
                    type: 'value',
                    name: '流量/次',
                    splitLine: {
                        show:false
                    },
                    interval: 5,
                    axisLabel: {
                        show: true,
                        textStyle: {
                            color: '#a4a7ab'
                        },
                    }
                }
            ],
            series : [
                {
                    name:'销售金额',
                    type:'line',
                    data:salelist,
                    smooth: true,
                    itemStyle: {
                        normal: {
                            color:"#e15828"
                        }
                    }
                },
                {
                    name:'客流量',
                    type:'line',
                    yAxisIndex: 1,
                    data:rlllist,
                    smooth: true,
                    itemStyle: {
                        normal: {
                            color:"#e9a832"
                        }
                    }
                }
            ]
        };
        myChart.setOption(option);
        window.addEventListener("resize",function(){
            myChart.resize();
        });
    })
}

//客单价
function averagePrice(){
    var xname=null;
    if(zytype == "0"){
        xname="小时";
    }else if(zytype == "1"){
        xname="日期";
    }
     $.get( "../../jxc/jxcsaleorder/averagePrice?type="+zytype+"&time="+zytime,function(r){
        var list=r.averagePricelist;
        var myChart = echarts.init(document.getElementById('kdj'));
        var option = {
        tooltip : {
            trigger: 'axis',
            formatter: function(params) { //自定义函数修改折线图给数据加单位
                var str = '';//声明一个变量用来存储数据
                str += '<div>'+ params[0].name +'</div>'; //显示首行的函数
                for(var i=0; i<params.length; i++) { //图显示的数据较多时需要循环数据，这样才可以成功的给多条数据添加单位
                    str += '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:'+params[i].color+';"></span>'+ params[i].seriesName +'</span> : <span>'+ params[i].data+'元' +'</br>';
                }
                return str;
            }
        },
        grid: {
            x: 46,
            y:30,
            x2:20,
            borderWidth: 0
        },
        calculable : true,
        xAxis : [
            {
                type : 'category',
                name:xname,
                boundaryGap : false,
                data :r.averagePricelist[0],
                splitLine: {
                    show: false
                },
                axisLabel: {
                    show: true,
                    textStyle: {
                        color: '#a4a7ab'
                    }
                }
            }
        ],
        yAxis : [
            {
                type: 'value',
                name: '客单价/元',
                splitLine: {
                    show: false
                },
                interval: 50,
                axisLabel: {
                    show: true,
                    textStyle: {
                        color: '#a4a7ab'
                    },
                }
            }
        ],
        series : [
            {
                name:'客单价',
                type:'line',
                data:r.averagePricelist[1],
                smooth: true,
                itemStyle: {
                    normal: {
                        color:"#e15828"
                    }
                }
            }
        ]
    };
    myChart.setOption(option);
    window.addEventListener("resize",function(){
        myChart.resize();
    });

    })

}
//时间选择
var zytype="0";
var zytime="";
function choicetime(data){
    if(data =="0"){
        zytype="0";
        $("#choiceday").css("display","inline-block");
        $("#choiceday").val("");
        $("#choicemonth").val("");
        zytime ="";
        $("#thisDay").css("background-color","#3366FF");
        $('#thisMonth').css("background-color","");
        $("#choicemonth").css("display","none");
        if(indexs==1){
            index1();
        }else if(indexs==2){
            index2();
        }else if(indexs==4){
            index4();
        }

    }else if(data =="1"){
        zytype="1";
        $("#choicemonth").css("display","inline-block");
        $("#choiceday").val("");
        $("#choicemonth").val("");
        zytime ="";
        $("#thisMonth").css("background-color","#3366FF");
        $('#thisDay').css("background-color","");
        $("#choiceday").css("display","none");
        if(indexs==1){
            index1();
        }else if(indexs==2){
            index2();
        }else if(indexs==4){
            index4();
        }

        /*kdj();
        salesCurve();
        dpSailChart1();
        averagePrice();
        allAly();*/
    }
}
//选择时间后 点击查询事件
function query(){
    //获取input框的值
    if(zytype =="0"){
        zytime =$("#choiceday").val();
    }else if(zytype=="1"){
        zytime =$("#choicemonth").val();
    }
    if(indexs==1){
        index1();
    }else if(indexs==2){
        index2();
    }else if(indexs==4){
        index4();
    }

}

//清空查询条件
function clearIf() {
    $("#choiceday").val("");
    $("#choicemonth").val("");
    zytype="0";
    zytime="";
    $("#thisDay").css("background-color","#3366FF");
    $('#thisMonth').css("background-color","");
}
 /****************第3标签方法结束*************************/

/****************第4标签方法结束*************************/
//小屏自动 手动推送 配置---南区
function xiaopingsendS(obj){
    var val = $(obj).val();
    if(val == 0){//启动自动推送
        //将车位接口自动推送标识位改成1
        var type = "sm1";
        $.get(baseURL + "screen/push/setScreenStatus/"+type, function(r){

        });
        //获取车位接口中车位剩余数，表示到页面---10s一次
        //getcountS();
        //clearInterval(xiaopingNgengxin);
        //xiaopingNgengxin = setInterval(getcountS,60000);

    }else if(val == 1){//关闭自动推送
        //清除定时任务
        //clearInterval(xiaopingNgengxin);
        var type = "sm2";
        $.get(baseURL + "screen/push/setScreenStatus/"+type, function(r){

        });
        //设置static中的标识
    }
}
//小屏自动 手动推送 配置---北区
function xiaopingsendN(obj){
    var val = $(obj).val();
    if(val == 0){//启动自动推送
        //将车位接口自动推送标识位改成1
        var type="nm1";
        $.get(baseURL + "screen/push/setScreenStatus/"+type, function(r){

        });
        //获取车位接口中车位剩余数，表示到页面---10s一次
        //getcountN();
        //clearInterval(xiaopingNgengxinN);
       // xiaopingNgengxinN = setInterval(getcountN,60000);

    }else if(val == 1){//关闭自动推送
        //清除定时任务
        //clearInterval(xiaopingNgengxinN);
        var type="nm2";
        $.get(baseURL + "screen/push/setScreenStatus/"+type, function(r){

        });
        //设置static中的标识
    }
}
function getcountS(){
    //获取车位数static数据
    $.get(baseURL + "screen/push/getParkCountS", function(r){
        var list = r.list;
        $("#bigparking").html(list[0]);
        $("#smallparking").html(list[1]);
    });

}
function getcountN(){
    //获取车位数static数据
    $.get(baseURL + "screen/push/getParkCountN", function(r){
        var list = r.list;
        $("#bigparkingN").html(list[0]);
        $("#smallparkingN").html(list[1]);
    });
}
//提示信息的显示--南区
function tishiS(obj){
    if($(obj).val()==24){
        $("#tishi1S").css("display","");
        $("#tishi2S").css("display","none");
    }else{
        $("#tishi2S").css("display","");
        $("#tishi1S").css("display","none");
    }
}
//提示信息的显示--北区
function tishiN(obj){
    if($(obj).val()==24){
        $("#tishi1N").css("display","");
        $("#tishi2N").css("display","none");
    }else{
        $("#tishi2N").css("display","");
        $("#tishi1N").css("display","none");
    }
}
//小屏推送S
function sengInfoSmallS(){
    var val1 = $("#tiaojian1SN input:checked").val();
    if(val1 == 0){
        alert("请先将推送模式设置为手动");
        return;
    }
    var val2 = $("#tiaojian2SN input:checked").val();
    var val3 = $("#tiaojian3SN input:checked").val();
    var color = "red";
    if(val3 == 1){
        color = "green";
    }else if (val3 == 2){
        color = "yellow";
    }
    var val4 = $("#tiaojian4SN").val();
    $("#infoS").html("<p style='color:"+color+";font-size: "+val2+"px;'>"+val4+"</p>");
    $.ajax({
        type: "POST",
        url: "../../screen/push/pushsmallS",
        data: {
            fontSize:val2,
            fontColor:val3,
            info:val4
        },
        success: function(n) {

        }
    });
}
//小屏推送N
function sengInfoSmallN(){
    var val1 = $("#tiaojian1N input:checked").val();
    if(val1 == 0){
        alert("请先将推送模式设置为手动");
        return;
    }
    var val2 = $("#tiaojian2N input:checked").val();
    var val3 = $("#tiaojian3N input:checked").val();
    var color = "red";
    if(val3 == 1){
        color = "green";
    }else if (val3 == 2){
        color = "yellow";
    }
    var val4 = $("#tiaojian4N").val();
    $("#infoN").html("<p style='color:"+color+";font-size: "+val2+"px;'>"+val4+"</p>");
    $.ajax({
        type: "POST",
        url: "../../screen/push/pushsmallN",
        data: {
            fontSize:val2,
            fontColor:val3,
            info:val4
        },
        success: function(n) {

        }
    });
}
//大屏自动-手动配置
function dapingsendS(obj){
    var val = $(obj).val();
    if(val == 0){
        //修改标识
        var type="sb1";
        $.get(baseURL + "screen/push/setScreenStatus/"+type, function(r){

        });
        //查询状态，更新截图
        //gengxinpicS();
        //clearInterval(dapingNgengxin);
        //dapingNgengxin = setInterval(gengxinpicS,60000);
    }else{
        //修改标识
        var type="sb2"
        $.get(baseURL + "screen/push/setScreenStatus/"+type, function(r){

        });
        //取消更新
        //clearInterval(dapingNgengxin);
    }
}
//大屏自动-手动配置
function dapingsendN(obj){
    var val = $(obj).val();
    if(val == 0){
        //修改标识
        var type="nb1"
        $.get(baseURL + "screen/push/setScreenStatus/"+type, function(r){

        });
        //查询状态，更新截图
       // gengxinpicN();
       // clearInterval(dapingNgengxinN);
       // dapingNgengxinN = setInterval(gengxinpicN,60000);
    }else{
        //修改标识
        var type="nb2";
        $.get(baseURL + "screen/push/setScreenStatus/"+type, function(r){

        });
        //取消更新
        //clearInterval(dapingNgengxinN);
    }
}
//更新大屏图片
function gengxinpicS(){
    $.ajax({
        type: "POST",
        url: "../../screen/push/pushbigS",
        data: {

        },
        success: function(r) {
            var list = r.list;
            if(list.length ==1){
                $("#statusbigS").html("当前屏幕状态：离线");
            }else{
                $("#statusbigS").html("当前屏幕状态：在线");
                $("#dapingpic").attr("src","/image1/"+list[1]);
            }

        }
    });
}
//更新大屏图片--北区
function gengxinpicN(){
    $.ajax({
        type: "POST",
        url: "../../screen/push/pushbigN",
        data: {

        },
        success: function(r) {
            var list = r.list;
            if(list.length ==1){
                $("#statusbigN").html("当前屏幕状态：离线");
            }else{
                $("#statusbigN").html("当前屏幕状态：在线");
                $("#dapingpicN").attr("src","/image2/"+list[1]);
            }

        }
    });
}


 /****************第4标签方法结束*************************/


 /****************第5标签方法开始*************************/
//车位统计
function cwStatistics(){
    $.get( "../../cw/cwparkingspace/cwCount?type="+zytype+"&time="+zytime,function(r){
        var slist=r.cwcountlist["南区"];
        var nlist=r.cwcountlist["北区"];
        var tlist=r.cwcountlist["总额"];
        $("#soutotal").html(slist[0]);
        $("#soubsy").html(slist[1]);
        $("#soubzyl").html(slist[2]+"%");
        $("#soussy").html(slist[3]);
        $("#souszyl").html(slist[4]+"%");

        $("#nortotal").html(nlist[0]);
        $("#norbsy").html(nlist[1]);
        $("#norbzyl").html(nlist[2]+"%");
        $("#norssy").html(nlist[3]);
        $("#norszyl").html(nlist[4]+"%");


        $("#ttotal").html(tlist[0]);
        $("#tbsy").html(tlist[1]);
        $("#tbzyl").html(tlist[2]+"%");
        $("#tssy").html(tlist[3]);
        $("#tszyl").html(tlist[4]+"%");
    })
}
//车位占用率 统计图
function cwzyl(){
    var xname=null;
    if(zytype == "0"){
        xname="小时";
    }else if(zytype == "1"){
        xname="日期";
    }
    var avg=[];
    /*var a=100/3;
        console.log(a.toFixed(1))*/
    $.get( "../../cw/cwparkingspace/cwStatistics?type="+zytype+"&time="+zytime,function(r){
        var soulist=r.southlist;
        var norlist=r.northlist;
        for (var i = 0; i <soulist[1].length ; i++) {
            avg.push(((parseFloat(soulist[1][i])+parseFloat(norlist[1][i]))/2).toFixed(1))
        }
        var myChart = echarts.init($("#zhanyonglv")[0]);
        option = {
            tooltip : {
                trigger: 'axis',
                formatter: function(params) { //自定义函数修改折线图给数据加单位
                    var str = '';//声明一个变量用来存储数据
                    str += '<div>'+ params[0].name +'</div>'; //显示首行的函数
                    for(var i=0; i<params.length; i++) { //图显示的数据较多时需要循环数据，这样才可以成功的给多条数据添加单位
                        str += '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:'+params[i].color+';"></span>'+ params[i].seriesName +'</span> : <span>'+ params[i].data+'%' +'</br>';
                    }
                    return str;
                }
            },
            grid: {
                x: 46,
                y:30,
                x2:30,
                y2:20,
                borderWidth: 0
            },

            calculable : false,
            legend: {
                data:['南区','北区','平均值',],
                textStyle:{
                    color:"#e9ebee"

                }
            },
            xAxis : [
                {
                    type : 'category',
                    name:xname,
                    data : soulist[0],
                    splitLine: {
                        show: false
                    },
                    axisLabel: {
                        show: true,
                        textStyle: {
                            color: '#a4a7ab',
                            align: 'center'
                        }
                    }

                }
            ],
            yAxis : [
                {
                    type : 'value',
                    name : '占用率',
                    max : 100 ,
                    axisLabel : {
                        formatter: '{value} %',
                        textStyle: {
                            color: '#a4a7ab',
                        }
                    },
                    splitLine: {
                        show: false
                    },
                }
            ],
            series : [

                {
                    name:'南区',
                    type:'bar',
                    data:soulist[1],
                    itemStyle: {
                        normal: {
                            color:"#0ad5ff"
                        }
                    }
                },
                {
                    name:'北区',
                    type:'bar',
                    data:norlist[1],
                    itemStyle: {
                        normal: {
                            color:"#005ea1"
                        }
                    }
                },
                {
                    name:'平均值',
                    type:'line',
                    data:avg,
                    itemStyle: {
                        normal: {
                            color:"#1afffd"
                        }
                    }
                }
            ]
        };
        myChart.setOption(option);
        window.addEventListener("resize",function(){
            myChart.resize();
        });
    })
}

//查询剩余车位
function queryParkingz(){
    $.get(baseURL + "cw/cwparkingspace/spaceShow", function(r){
        $("#ln").html(r.p1);
        $("#ftn").html(r.p2);
        $("#fbn").html(r.p3);
        $("#btn").html(r.p4);
        $("#fcn").html(r.p5);
        $("#ls").html(r.p6);
        $("#fts").html(r.p7);
        $("#fbs").html(r.p8);
        $("#bts").html(r.p9);
        $("#fcs").html(r.p10);

    });

}

 /****************第5标签方法结束*************************/


 /****************第6标签方法开始*************************/
 var setting = {
     view: {
         fontCss : {color:"white"},
     },
     data: {
         simpleData: {
             enable: true,
             idKey: "id",
             pIdKey: "parentId",
             rootPId: -1
         },
         key: {
             url:"nourl"
         }
     },
     /* check: {
          enable: true ,//显示复选框
          chkStyle : "radio"
      },*/
     callback:{
         onClick: click// 点击事件回调函数
     }
 };
var ztree;
var s_setting = {
    /*view: {
        fontCss : {color:"white"},
    },*/
    data: {
        simpleData: {
            enable: true,
            idKey: "id",
            pIdKey: "parentId",
            rootPId: -1
        },
        key: {
            url:"nourl"
        }
    },
    /* check: {
         enable: true ,//显示复选框
         chkStyle : "radio"
     },*/
    callback:{
        onClick: click// 点击事件回调函数
    }
};
var s_ztree;
var n_setting = {
    /* view: {
         fontCss : {color:"white"},
     },*/
    data: {
        simpleData: {
            enable: true,
            idKey: "id",
            pIdKey: "parentId",
            rootPId: -1
        },
        key: {
            url:"nourl"
        }
    },
    /* check: {
         enable: true ,//显示复选框
         chkStyle : "radio"
     },*/
    callback:{
        onClick: click// 点击事件回调函数
    }
};
var n_ztree;
function click(event, treeId, treeNode){
    if(treeNode.isClick){
        $("#cName").html("当前监控点："+treeNode.name);
        $("#cName").attr("name",treeNode.data);
        $("#errMessage").text("");
        if(playMode==0){
            startPreview(treeNode.data);
        }

    }
};
//监控页监控列表
$(function(){
    $.get( "../../jk/jkcamara/indexsCamaraTree",function(r){
        ztree = $.fn.zTree.init($("#indexsCamaraTree"), setting,r.indexsTree);
        var nodes=ztree.transformToArray(ztree.getNodes());
        for(var i=0;i<nodes.length;i++){
            if(nodes[i].level==0){
                ztree.expandNode(nodes[i], true, true, true);
            }else{
                ztree.expandNode(nodes[i], false, true, true);
            }
        }
    })
});
var southlist=[];
var northlist=[];
//南北区所有监控集合
$(function(){
    $.get( "../../jk/jkcamara/northSouthCamara",function(r){
        var south= r.southCamaraTree;//南区
        var north= r.northCamaraTree;//北区
        n_ztree = $.fn.zTree.init($("#northTree"), n_setting,north);
        s_ztree = $.fn.zTree.init($("#southTree"), s_setting,south);
        var n_nodes=n_ztree.transformToArray(n_ztree.getNodes());
        for(var i=0;i<n_nodes.length;i++){
            if(n_nodes[i].level==0){
                n_ztree.expandNode(n_nodes[i], true, true, true);
            }else{
                n_ztree.expandNode(n_nodes[i], false, true, true);
            }
        }
        var s_nodes=s_ztree.transformToArray(s_ztree.getNodes());
        for(var i=0;i<s_nodes.length;i++){
            if(s_nodes[i].level==0){
                s_ztree.expandNode(s_nodes[i], true, true, true);
            }else{
                s_ztree.expandNode(s_nodes[i], false, true, true);
            }
        }
        var sinfo="";
        var ninfo="";
        var count=0;
        var count1=0;
        for(var i=0;i<south.length;i++){
            if(count<4){
                if(south[i].isClick){
                    southlist.push(south[i]);
                    sinfo +="<span name="+south[i].data+" onclick='southCamara(this)' class='year_chose camaraRow1'>"+south[i].name+"</span>";
                    count ++;
                }
            }else if(count<7){
                if(south[i].isClick){
                    southlist.push(south[i]);
                    sinfo +="<span name="+south[i].data+" onclick='southCamara(this)' class='year_chose camaraRow2'>"+south[i].name+"</span>";
                    count ++;
                }
            }
        }
        sinfo +="<span name='sou' onclick='morethan(this)' class='year_chose camaraRow2'>更多</span>"
        $("#south").append(sinfo);
        for(var i=0;i<north.length;i++){
            if(count1<4){
                if(north[i].isClick){
                    northlist.push(north[i])
                    ninfo +="<span name="+north[i].data+" onclick='northCamara(this)' class='year_chose camaraRow1'>"+north[i].name+"</span>";
                    count1 ++;
                }
            }else if(count1<7){
                if(north[i].isClick){
                    northlist.push(north[i])
                    ninfo +="<span name="+north[i].data+" onclick='northCamara(this)' class='year_chose camaraRow2'>"+north[i].name+"</span>";
                    count1 ++;
                }
            }
        }
        ninfo +="<span name='nor' onclick='morethan(this)' class='year_chose camaraRow2'>更多</span>"
        $("#north").append(ninfo);
    })
});

function southCamara(data){
    var camaraIndexCode=$(data).attr("name");
    startPreview1(camaraIndexCode,-1);
}
function northCamara(data){
    var camaraIndexCode=$(data).attr("name");
    startPreview2(camaraIndexCode,-1);
}
function morethan(data){
    var name=$(data).attr("name");
    if(name =="sou"){
        layer.open({
            type: 1,
            offset: ['270px','1350px'],
            skin: 'layui-layer-molv',
            title: "南区监控列表",
            area: ['300px', '450px'],
            shade: 0,
            shadeClose: false,
            content: jQuery("#southLayer"),
            btn: ['确定', '取消'],
            btn1: function (index) {
                var checkedNodes=s_ztree.getSelectedNodes();//所选择节点
                if(checkedNodes[0].isClick){
                    //console.log(checkedNodes[0].data+"------------点击后----------")
                    startPreview1(checkedNodes[0].data,-1);
                }
                layer.close(index);
            }
        })
    }else if(name =="nor"){
        layer.open({
            type: 1,
            offset: ['270px','1350px'],
            skin: 'layui-layer-molv',
            title: "北区区监控列表",
            area: ['300px', '450px'],
            shade: 0,
            shadeClose: false,
            content: jQuery("#northLayer"),
            btn: ['确定', '取消'],
            btn1: function (index) {
                var checkedNodes=n_ztree.getSelectedNodes();//所选择节点
                if(checkedNodes[0].isClick){

                }
                layer.close(index);
            }
        })
    }
}

 /****************第6标签方法结束*************************/